package com.jvm;

/**
 * 使用Xss 减少栈内存容量，结果：抛出StackOverflowError异常，异常出现时输出的堆栈深度相应缩小。
 */
public class JavaVMStackSOF {

    private int stackLength = 1;

    public void stackLeak(){
        stackLength++;
        stackLeak();
    }

    public static void main(String[] args) throws Throwable{
        JavaVMStackSOF oom  = new JavaVMStackSOF();
        try {
            oom.stackLeak();
        } catch (Throwable e) {
            System.out.println("stack length: "+oom.stackLength);
            throw e;
        }
    }
}
